
<%@ page contentType="text/html; charset=utf-8" 
%><%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" 
%><%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" 
%><%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" 
%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>filedownload.jsp</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="${pageContext.request.contextPath}/js/jquery/jquery-1.11.0.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" media="screen" href="${pageContext.request.contextPath}/js/jquery/ui/css/redmond/jquery-ui-1.10.4.custom.css" />
<script src="${pageContext.request.contextPath}/js/jquery/ui/js/jquery-ui-1.10.4.custom.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/jquery/file-download/jquery.fileDownload.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
	$(document).on("click", "a.fileDownloadPromise", function () {
// 	    $.fileDownload($(this).prop('href'))
// 	        .done(function () { alert('File download a success!'); })
// 	        .fail(function () { alert('File download failed!'); });

        $.fileDownload($(this).prop('href'), {
        	failCallback: function(responseHtml, url) {
        		alert('File download failed!');
        	}
        });

	    return false; //this is critical to stop the click event which will trigger a normal file download
	});	
});	
</script>
</head>
<body>
<a class="fileDownloadPromise" href="${pageContext.request.contextPath}/app/file/download2">download2</a><br/>
<a class="fileDownloadPromise" href="${pageContext.request.contextPath}/app/file/download3">download3</a>
</body>
</html>